#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<stdlib.h>
int* countBits(int n, int* returnSize)
{
    int* arr = (int*)malloc(sizeof(int) * (n + 1));
    int k = 0;
    for (int i = 0; i <= n; i++)
    {
        arr[k] = 0;
        int j = i;
        while (j)
        {
            if ((j & 1) == 1)
                arr[k]++;
            j = j >> 1;
        }
        k++;
    }
    *returnSize = n + 1;
    return arr;
}